<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input id="mingzi" placeholder="输入姓名" />
    <input type="button" value="图片" onclick="xianshi()"/>
  <script>
    function xianshi(){
        if(mingzi.value=="胖子"){
            document.write("<img src='2.jpg' />");
        }
        if(mingzi.value=="小夫"){
            document.write("<img src='3.jpg' />");
        }
        if(mingzi.value=="大熊"){
            document.write("<img src='4.jpg' />");
        }
    }
  </script>
</body>
</html>